var name = 'hello';

function upperCase(str) {
    let arr = str.split("");
    let newStr = "";
    // 通过数组的forEach方法来遍历数组
    arr.forEach(function (value) {
        if (value >= 'a' && value <= 'z')
            newStr += value.toUpperCase();
        else
            newStr += value;
    });
    return newStr;
}
document.write(upperCase(name));